﻿using System.Reflection;
class Program
{
    static void Main()
    {
        //反射调用带参数的构造函数
        Type type = typeof(Person);
        ConstructorInfo constructor = type.GetConstructor(new Type[] { typeof(string), typeof(bool), typeof(int) });
        object obj = constructor.Invoke(new object[] { "测试人员", true, 20 });
        Person person = (Person)obj;
        Console.WriteLine(person.Name);
        if (person.sex)
            Console.WriteLine("男");
        else
            Console.WriteLine("女");
        Console.WriteLine(person.Age);
    }
}

public class Person
{
    public string Name { get; set; }

    //false表示女性，true表示男性
    public bool sex { get; set; }
    public int Age { get; set; }    

    public Person() { }
    public Person(string name, bool sex, int age) => 
        (Name, this.sex, Age) = (name, sex, age);

}
